package cn.sunshine.controller;

import cn.sunshine.domain.Product;

import cn.sunshine.domain.Result;
import cn.sunshine.domain.Store;
import cn.sunshine.feign.ProductFeginClient;
import cn.sunshine.mapper.StoreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StoreController {
    @Autowired
    private StoreMapper storeMapper;
    @Autowired
    private ProductFeginClient productFeginClient;
    // @GetMapping("/store/{product1}")
   // @RequestMapping(value = "/store", method = RequestMethod.GET)
    /*@PostMapping("/store/add")
    public Result add(@RequestBody Store store) {
        *//*Store store = new Store();
        store.setProduct_id(product.getId());
        store.setNumber(product.getNumber());*//*
        storeMapper.add(store);
        return new Result();
    }*/
    @PostMapping("/store/add")
    public Result add(@RequestBody Product product) {
        Store store = new Store();
        store.setProductId(product.getId());
        store.setNumber(product.getNumber());
        storeMapper.add(store);
        //return Result.builder().success(true).message("true!").build();
        return new Result();
    }
}
